<?php 

class LoginController extends Controller{
	private $db;
	public function __init()
	{
		$this->db=new AdminModel;
	}
	public function index()
	{
		$data=$this->db->userInfor();
		$this->assign('user',$data);
		$this->display('userInfor.html');
	}
	//登录
	public function login()
	{
		if (IS_POST) {
			if ($this->db->userLogin()) {
				$this->success('登录成功',__MODEL__);
			}else{
				$this->error($this->db->error);
			}
		}else{
			$this->display('login.html');
		}
		
	}

	//退出
	public function out()
	{
		session_unset($_SESSION);
		session_destroy();
		$this->success("退出成功",__MODEL__.'&c=Login&a=login');
	}

	//修改密码
	public function edit()
	{
		if (IS_POST) {
			if ($this->db->editLogin($_POST)) {
				session_unset();//修改后删除$_SESSION
				$this->display('Refresh.html');
			}else{
				$this->error($this->db->error);
			}
		}else{
			$this->display('edit.html');
		}
	}

	//修改个人信息
	public function editInfor()
	{
		if (IS_POST) {
			if ($this->db->editUserinfor($_POST)) {
				$this->success("修改成功",__MODEL__.'&c=Login');
			}else{
				$this->error($this->db->error);
			}
		}else{
			$this->display('editInfor.html');
		}
		
	}

}

 ?>